package linter.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import linter.POJO.DO.NoteCommunity;
import linter.service.NoteCommunityService;
import linter.mapper.NoteCommunityMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

import static linter.custom.CustomResultType.CREATION_ERROR;
import static linter.custom.CustomResultType.CREATION_SUCCESS;

/**
* @author 北煜
* @description 针对表【note_community(笔记是否共享表)】的数据库操作Service实现
* @createDate 2024-04-14 23:45:23
*/
@Service
public class NoteCommunityServiceImpl extends ServiceImpl<NoteCommunityMapper, NoteCommunity>
    implements NoteCommunityService{
    @Resource
    NoteCommunityMapper noteCommunityMapper;

    @Override
    public String isShareNote(Long uuid, int isShare, Long noteId) {
        Date date = new Date();
        NoteCommunity noteCommunity = new NoteCommunity();
        noteCommunity.setNoteid(noteId);
        noteCommunity.setUuid(uuid);
        noteCommunity.setIsShare(isShare);
        noteCommunity.setUpdateTime(date);
        int flag = noteCommunityMapper.insert(noteCommunity);
        return  flag != 1 ? CREATION_ERROR : CREATION_SUCCESS;
    }
}




